<template>
  <div class="wrap wrap_kefu">
    <img src="/static/img/kefu.png" alt="" class="kefu_pic">
    <div class="kefu_desc">
      我们将会全心全意为您提供满意周到的咨询服务，也希望您能支持和监督我们的服务！
    </div>
    <div class="kefu_btns">
      <div class="btn_kefu" @click="callTel(item)"
          v-for="(item, index) in tels"
          :key="index">
        {{item.text}}
      </div>
    </div>
  </div>
</template>

<script>
import fly from '@/utils/fly'

export default {
  data () {
    return {
      tels: []
    }
  },
  computed: {},
  methods: {
    async getTel () {
      this.canLoadMore = false

      let url = `Index/getServiceTel`
      let res = await fly.post(url)

      if (res && res.code === 200 && res.data) {
        this.tels = res.data
      } else {
        wx.showToast({
          title: `数据异常${res ? ('(' + res.code + ')') : ''}`,
          icon: 'none'
        })
      }
      this.canLoadMore = true
    },
    callTel (item) {
      wx.makePhoneCall({
        phoneNumber: '' + item.tel
      })
    }
  },
  async onLoad () {
    wx.showLoading({
      title: '加载中'
    })
    await this.getTel()
    wx.hideLoading()

    wx.setNavigationBarTitle({
      title: '联系客服'
    })
  }
}
</script>

<style lang="scss">
@import "./kefu.scss";
</style>
